﻿using System;
using System.Collections.Generic;
using System.Linq;
using ExpenseSystem.Common;
using ExpenseSystem.Fether;
using ExpenseSystem.Model;
using ExpenseSystem.Lor;

namespace ExpenseSystem.Fether
{
    public class SalesPointEmployeeFetcher : NormalFetcher<SalesPointEmployeeModel>,IDetailFetcher<SalesPointEmployeeModel>
    {
        public SalesPointEmployeeModel GetByEmployee( long site, long employee, out string message)
        {
            IList<SalesPointEmployeeModel> result = List( site, OrderBy.GetDefault(), Limit.GetDefault(), out message, out  rows, Restrain.Eq("EmployeeId", employee).And(Restrain.Eq("Avaliable", true)));
            if (result.Count > 0)
                return result.First();
            return null;
        }

        public IList<SalesPointEmployeeModel> ListByMainId( long site, long mainId, out string message, out int rows)
        {
            IList<SalesPointEmployeeModel> result = List( site, OrderBy.GetDefault(), Limit.GetDefault(), out message, out  rows, Restrain.Eq("SalesPointId", mainId).And(Restrain.Eq("Avaliable", true)));

            return result;
        }
    }
}
